package com.latamcloud.files;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class WriteFiles {
	
	public void writeFile(String nFile) {
		  // Create file 
		FileWriter fstream;
		try 
		{
			fstream = new FileWriter("out.txt");
			BufferedWriter out = new BufferedWriter(fstream);
			out.write("Hello Java");
			out.close();			  
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void writeFile(String nFile, String text) {
		  // Create file 
		FileWriter fstream;
		try 
		{
			fstream = new FileWriter(nFile);
			BufferedWriter out = new BufferedWriter(fstream);
			out.write(text);
			out.close();			  
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void appendFile(String nFile, String text) {
		  // Create file 
		FileWriter fstream;

		
		try 
		{
			fstream = new FileWriter(nFile,true);
			BufferedWriter out = new BufferedWriter(fstream);
			out.write(text);
			out.close();			  
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}